Hệ thống quản lý trường đại học bằng PHP

1 <!DOCTYPE html>
2 <html>
3 <head><title>File Upload To Database</title></head>
4 <body>
5     <form enctype=
"multipart/form-data" action="upload.php" method="POST">
6         <input type=
"file" name="image" >
7         <input type=
"submit" name="submit" value="submit">
8     </form>
9   <?php
10   
if(isset($_POST['submit']))
11   {
12
13    require(
'includes/config.php');
14 $imagename = addslashes($_FILES[
"image"]["name"]);
15 $imagedata =addslashes(file_get_contents($_FILES[
"image"]["tmp_name"]));
16 $imagetype = addslashes($_FILES[
"image"]["type"]);
17  
if (substr($imagetype,0,5)=="image") {
18     $stmt = $db->query(
"INSERT INTO Uploadedimages VALUES ('','$imagename','$imagedata')");
19  }
20  
else
21  {
22     echo
"not an image";
23  }
24 }
25    ?>
26 </body>
27 </html>


Gõ tìm kiếm nhanh...